#ifndef _RESOURCE_H
#define _RESOURCE_H


#define GUI_KEYBOARD_MODE     1

#define MSG_SETDATA        MSG_USER + 1
#define MSG_KEYPANECLOSE   MSG_USER + 2
#define MSG_KEYPANE_ESC    MSG_KEYPANECLOSE
#define MSG_KEYPANE_ENTER  MSG_SETDATA
#define MSG_GOTO_LINE      MSG_USER + 3
#define MSG_LEFT           MSG_USER + 4
#define MSG_RIGHT          MSG_USER + 5
#define MSG_DOWN           MSG_USER + 6
#define MSG_UP             MSG_USER + 7
#define MSG_RESET          MSG_USER + 8
#define MSG_FLUSH         MSG_USER + 9
#define MSG_UPDATE       MSG_USER + 10


#define SCANCODE_MINUS_USER      118

#define ID_BTN_BACK        3000
#define ID_BTN_RUN         3001
#define ID_BTN_PRG         3002
#define ID_BTN_FLW         3003
#define ID_BTN_FILE        3004
#define ID_BTN_SYS         3005
#define ID_BTN_WORK        3006
#define ID_BTN_HEAD        3007
#define ID_BTN_MAC         3008
#define ID_BTN_SPEED       3009
#define ID_BTN_RESET       3010
#define ID_BTN_HD          3011
#define ID_PIECE_LOCK      3012
#define ID_WARN_ENABLE     3013
#define ID_YARN_UP         3014
#define ID_ROLL            3015
#define ID_GOTO_LINE       3016
#define ID_STOP_LINE       3017
#define ID_SPREAD          3018
#define ID_BOARD_TEST      3019
#define ID_YARN_INIT       3020
#define ID_LIGHT           3021
#define ID_YARN_FEEDER     3022
#define ID_KNIT_NUM_SET    3023
#define ID_SINK            3024
#define ID_START_POINT     3025
#define ID_CYCLE           3026
#define ID_DUMU            3027
#define ID_SPEED           3028
#define ID_MAST_ROLL       3029
#define ID_BOARD           3030
#define ID_YARN_STOP       3031
#define ID_PAGE_UP         3032
#define ID_PAGE_DOWN       3033
#define ID_ROCK            3034
#define ID_DUMU1           3035
#define ID_DUMU2           3036
#define ID_ROLL_SWITCH     3037
#define ID_YARN_CHANGE     3038
#define ID_AUX_ROLL        3039
#define ID_YARN_EXCHANGE   3040
#define ID_TYPE            3041
#define ID_RSVD            3042
#define ID_SCISSOR         3043
#define ID_CLIP_ON         3044
#define ID_CLIP_OFF        3045
#define ID_ECONOMY         3046
#define ID_PARAM_EXCHANGE  3047
#define ID_LEFT_YARN_IN    3048
#define ID_LEFT_YARN_OUT   3049
#define ID_0NUM            3049
#define ID_LEFT_1YARN      3050
#define ID_FILE_1IO        3050
#define ID_1NUM            3050
#define ID_LEFT_2YARN      3051
#define ID_FILE_2IO        3051
#define ID_2NUM            3051
#define ID_LEFT_3YARN      3052
#define ID_FILE_3IO        3052
#define ID_3NUM            3052
#define ID_LEFT_4YARN      3053
#define ID_FILE_4IO        3053
#define ID_4NUM            3053
#define ID_LEFT_5YARN      3054
#define ID_FILE_5IO        3054
#define ID_5NUM            3054
#define ID_LEFT_6YARN      3055
#define ID_FILE_6IO        3055
#define ID_6NUM            3055
#define ID_LEFT_7YARN      3056
#define ID_FILE_7IO        3056
#define ID_7NUM            3056
#define ID_LEFT_8YARN      3057
#define ID_FILE_8IO        3057
#define ID_8NUM            3057
#define ID_LEFT_11YARN     3058
#define ID_CYCLE_START     3058
#define ID_9NUM            3058
#define ID_LEFT_12YARN     3059
#define ID_CYCLE_END       3059
#define ID_10NUM           3059
#define ID_LEFT_13YARN     3060
#define ID_CYCLE_NUM       3060
#define ID_11NUM           3060
#define ID_LEFT_14YARN     3061
#define ID_CYCLE_LEFT      3061
#define ID_12NUM           3061
#define ID_LEFT_15YARN     3062
#define ID_13NUM           3062
#define ID_LEFT_16YARN     3063
#define ID_14NUM           3063
#define ID_LEFT_17YARN     3064
#define ID_15NUM           3064
#define ID_LEFT_18YARN     3065
#define ID_16NUM           3065
#define ID_RGHT_1YARN      3066
#define ID_17NUM           3066
#define ID_RGHT_2YARN      3067
#define ID_18NUM           3067
#define ID_RGHT_3YARN      3068
#define ID_19NUM           3068
#define ID_RGHT_4YARN      3069
#define ID_20NUM           3069
#define ID_RGHT_5YARN      3070
#define ID_21NUM           3070
#define ID_RGHT_6YARN      3071
#define ID_22NUM           3071
#define ID_RGHT_7YARN      3072
#define ID_23NUM           3072
#define ID_RGHT_8YARN      3073
#define ID_24NUM           3073
#define ID_RGHT_11YARN     3074
#define ID_25NUM           3074
#define ID_RGHT_12YARN     3075
#define ID_26NUM           3075
#define ID_RGHT_13YARN     3076
#define ID_27NUM           3076
#define ID_RGHT_14YARN     3077
#define ID_28NUM           3077
#define ID_RGHT_15YARN     3078
#define ID_29NUM           3078
#define ID_RGHT_16YARN     3079
#define ID_30NUM           3079
#define ID_RGHT_17YARN     3080
#define ID_31NUM           3080
#define ID_RGHT_18YARN     3081
#define ID_32NUM           3081
#define ID_RGHT_YARN_IN    3082
#define ID_RGHT_YARN_OUT   3083
#define ID_UP              3084
#define ID_DOWN            3085
#define ID_LEFT            3086
#define ID_RGHT            3087
#define ID_EDIT            3088
#define ID_ZOOM_OUT        3089
#define ID_ZOOM_IN         3090
#define ID_OTHER_PARAM     3091
#define ID_INIT_PARAM      3092
#define ID_WRITE_PARAM     3093
#define ID_READ_PARAM      3094
#define ID_DMBZ            3095
#define ID_TRAN_ROCK       3096
#define ID_PLUS_TRAN_ROCK  3097
#define ID_DEC_TRAN_ROCK   3098
#define ID_ROCK_POS        3099
#define ID_DMBZ1           3096
#define ID_DMBZ2           3097
#define ID_DMBZ3           3098
#define ID_DMBZ4           3099
#define ID_BOARD_PARAM     3100
#define ID_TIME_SET        3101
#define ID_TOUCH_SCREEN    3102
#define ID_YARN_SPEED      3103
#define ID_DUMU_BEFORE     3104
#define ID_TURN_OFF        3105
#define ID_HELP            3106
#define ID_YARN_POS        3107
#define ID_SWITCH_ROLL     3108
#define ID_VERSION         3109
#define ID_BELT            3110
#define ID_CLEAR           3111
#define ID_DELETE          3112
#define ID_TIME            3113
#define ID_UPDATE          3114
#define ID_RAB_VALUE       3115
#define ID_ROLL_VALUE      3116
#define ID_RAB             3117
#define ID_ROCK_SPEED      3118
#define ID_INTASIA         3119
#define ID_RET_LEN         3120
#define ID_LEFT_FEEDER     3121
#define ID_RIGHT_FEEDER    3122
#define ID_LEFT_YARN       3123
#define ID_RGHT_YARN       3124
#define ID_START_LINE      3125
#define ID_END             3126
#define ID_MOVE            3127
#define ID_ENTER           3128
#define ID_ESC             3129
#define ID_DEL             3130
#define ID_COPY            3131
#define ID_ROCK_DRIVE             3132
#define ID_RUDE                           3133
#define ID_DROP                          3134
#define ID_ZOOM                         3135
#define ID_MAC_BEFORE           3136
#define ID_YARN_BEFORE          3137
#define ID_MAC_PARAM            3138
#define ID_YARN_BEFORE_SET  3139
#define ID_DAT_1NUM                 3140
#define ID_DAT_AUTO                  3141
#define ID_DAT_ESC                     3142
#define ID_SINK_RESET               3143
#define ID_SINK_COPY                3144
#define ID_CAM_SETTING           3145
#define ID_CAM_RESET                3146
#define ID_CAM_COPY                 3147
#define ID_BTN_ROCK                 3148
#define ID_TRUE                            3149
#define ID_FALSE                          3150

#define IDC_FILE_NAME      4000
#define IDC_KNIT_NUM       4001
#define IDC_TOTAL_LINE     4002
#define IDC_KNIT_TIME      4003
#define IDC_MAC_POS        4004
#define IDC_KNIT_FINISHED  4005
#define IDC_LINE_FINISHED  4006
#define IDC_EFFICIENCY     4007
#define IDC_ROCK           4008
#define IDC_INTER          4009
#define IDC_CYCLE          4011
#define IDC_SINK           4012
#define IDC_START_POINT    4013
#define IDC_DUMU           4014
#define IDC_SPEED          4015
#define IDC_MAST_ROLL      4016
#define IDC_BOARD          4017
#define IDC_YARN_STOP      4018
#define IDC_LEFT_DRT       4019
#define IDC_RIGHT_DRT      4020
#define IDC_DUMU1_NAME     4021
#define IDC_DUMU2_NAME     4022
#define IDC_DUMU3_NAME     4023
#define IDC_DUMU4_NAME     4024
#define IDC_BACK_ROW       4025
#define IDC_FRONT_ROW      4026
#define IDC_CMD_FA         4027
#define IDC_CMD_FH         4028
#define IDC_CMD_BA         4029
#define IDC_CMD_BH         4029
#define IDC_YARN           4030
#define IDC_CODE_BA        4031
#define IDC_CODE_BH        4032
#define IDC_CODE_FA        4033
#define IDC_CODE_FH        4034
#define IDC_ROCK_SPEED     4035
#define IDC_INTASIA        4036
#define IDC_DUMU_BEFORE    4037
#define IDC_RET_LEN        4038
#define IDC_CYCLE_START    4039
#define IDC_CYCLE_END      4040
#define IDC_CYCLE_NUM      4041
#define IDC_CYCLE_LEFT     4042
#define IDC_DMBZ           4043
#define IDC_DUMU5_NAME     4044
#define IDC_DUMU6_NAME     4045
#define IDC_DUMU7_NAME     4046
#define IDC_DUMU8_NAME     4047
#define IDC_TIP            4048
#define IDC_RUDE           4049

#define IDC_EDIT_HD             4997
#define IDC_EDIT_DUMU1          4998
#define IDC_EDIT_DUMU_RESET     4999
#define IDC_EDIT_DUMU2          5000
#define IDC_EDIT_DUMU_WORK      5001
#define IDC_EDIT_ROCK           5002
#define IDC_EDIT_SPEED          5003
#define IDC_EDIT_MAST_ROLL      5004
#define IDC_EDIT_ROLL_SWITCH    5005
#define IDC_EDIT_AUX_ROLL       5005
#define IDC_EDIT_RSVD           5006
#define IDC_EDIT_TYPE           5007
#define IDC_EDIT_YARN_STOP      5008
#define IDC_EDIT_SCISSOR        5009
#define IDC_EDIT_CLIP_ON        5010
#define IDC_EDIT_CLIP_OFF       5011
#define IDC_EDIT_BOARD_USED     5012
#define IDC_EDIT_ECONOMY        5013
#define IDC_EDIT_BACKL_ROW      5014
#define IDC_EDIT_FRNTL_ROW      5015
#define IDC_EDIT_BACKR_ROW      5016
#define IDC_EDIT_FRNTR_ROW      5017
#define IDC_EDIT_LEFT_CMD_BA    5018
#define IDC_EDIT_LEFT_CODE_BA   5019
#define IDC_EDIT_LEFT_CMD_BH    5020
#define IDC_EDIT_LEFT_CODE_BH   5021
#define IDC_EDIT_LEFT_CMD_FA    5022
#define IDC_EDIT_LEFT_CODE_FA   5023
#define IDC_EDIT_LEFT_CMD_FH    5024
#define IDC_EDIT_LEFT_CODE_FH   5025
#define IDC_EDIT_RGHT_CMD_BA    5026
#define IDC_EDIT_RGHT_CODE_BA   5027
#define IDC_EDIT_RGHT_CMD_BH    5028
#define IDC_EDIT_RGHT_CODE_BH   5029
#define IDC_EDIT_RGHT_CMD_FA    5030
#define IDC_EDIT_RGHT_CODE_FA   5031
#define IDC_EDIT_RGHT_CMD_FH    5032
#define IDC_EDIT_RGHT_CODE_FH   5033
#define IDC_LEFT_CAM            5034
#define IDC_RGHT_CAM            5035
#define IDC_EDIT_X              5036
#define IDC_EDIT_Y              5037
#define IDC_EDIT_WIDTH          5038
#define IDC_EDIT_HEIGHT         5039
#define IDC_EDIT_FILE_NAME      5040
#define IDC_EDIT_INCH_TYPE                 5041
#define IDC_EDIT_TOTAL_NEEDLE              5042
#define IDC_EDIT_TOTAL_PULSE               5043
#define IDC_EDIT_NEEDLE_ZERO               5044
#define IDC_EDIT_LEFT_YARN_RGHT_ZERO       5045
#define IDC_EDIT_LEFT_YARN_LEFT_ZERO       5046
#define IDC_EDIT_RGHT_YARN_RGHT_ZERO       5047
#define IDC_EDIT_RGHT_YARN_LEFT_ZERO       5048
#define IDC_EDIT_SELECT_RGHT_COM           5049
#define IDC_EDIT_SELECT_LEFT_COM           5050
#define IDC_EDIT_HEAD_LEFT_FORBID          5051
#define IDC_EDIT_HEAD_RGHT_FORBID          5052
#define IDC_EDIT_SINK_ENABLE               5053
#define IDC_EDIT_ROCK_SPEED                5054
#define IDC_EDIT_MID_ROCK                  5055
#define IDC_EDIT_LOW_ROCK                  5056
#define IDC_EDIT_YARN_STOP_COM             5057
#define IDC_EDIT_SELECT_ENV                5058
#define IDC_EDIT_ROCK_COM                  5059
#define IDC_EDIT_PULSE_COM                 5060
#define IDC_EDIT_SELECT_SECT               5061
#define IDC_EDIT_CAM_TYPE                  5062
#define IDC_EDIT_READ_SIGN                 5063
#define IDC_EDIT_LOCK_CAM                  5064
#define IDC_EDIT_CLOTH                     5065
#define IDC_EDIT_INTER                     5066
#define IDC_EDIT_HIGH_CAM                  5067
#define IDC_EDIT_HIGH_XZQ                  5068
#define IDC_EDIT_LOW_XZQ                   5069
#define IDC_EDIT_BELT_INTER                5070
#define IDC_EDIT_XZQ_REPEAT                5071
#define IDC_EDIT_LANGUAGE                  5078
#define IDC_EDIT_HEAD_MOVE_ENABLE          5079
#define IDC_EDIT_ROCK_TYPE                 5080
#define IDC_EDIT_ROLL_OPEN                 5081
#define IDC_EDIT_RAB_PERCENT               5082
#define IDC_EDIT_LOW_SPEED                 5083
#define IDC_EDIT_MID_SPEED                 5084
#define IDC_EDIT_HIGH_SPEED                5085
#define IDC_EDIT_RESET_SPEED               5086
#define IDC_EDIT_START_POINT               5087
#define IDC_EDIT_YARN_BEFORE               5088
#define IDC_EDIT_HIGH_LINE_SPEED           5089
#define IDC_EDIT_RAB_STOP                  5090
#define IDC_EDIT_RET_LEN                   5091
#define IDC_EDIT_BACK_SINK_RESET           5092
#define IDC_EDIT_SCREEN_SAVE_TIME          5093
#define IDC_EDIT_SCREEN_SAVE_ENABLE        5094
#define IDC_EDIT_RAB_WARN_ENABLE           5095
#define IDC_EDIT_FRONT_SAFE_DOOR           5096
#define IDC_EDIT_BACK_SAFE_DOOR            5097
#define IDC_EDIT_FRONT_SHAKE_SENSE         5098
#define IDC_EDIT_BACK_SHAKE_SENSE          5099
#define IDC_EDIT_AUTO_RESET_NUM            5100
#define IDC_EDIT_FRONT_SINK_RESET          5101
#define IDC_EDIT_SHAKE_ENABLE              5102
#define IDC_EDIT_BOARD_ENABLE              5103
#define IDC_EDIT_SCISSOR_ENABLE            5104
#define IDC_EDIT_RAB_OPEN                  5105
#define IDC_SELECT_START_SECT              5106
#define IDC_EDIT_2DUMU                     5107
#define IDC_EDIT_YF                        5108
#define IDC_EDIT_PROBE                     5109
#define IDC_EDIT_DUMU_ADD                  5110
#define IDC_TAKE_YARN_MODE                 5111
#define IDC_EDIT_TRAN_DUMU                 5112
#define IDC_EDIT_YARN_MODE_TAKE          5113
#define IDC_EDIT_AUTO_LINE_SET                5114
#define IDC_EDIT_RETURN_STATE                 5115
#define IDC_EDIT_COPY_RAB_ENABLE         5116

#define IDC_EDIT_SELECT1_TO_MAC_LEFT_LEN                               5117
#define IDC_EDIT_SELECT2_TO_MAC_LEFT_LEN                               5118
#define IDC_EDIT_SELECT3_TO_MAC_LEFT_LEN                               5119
#define IDC_EDIT_SELECT4_TO_MAC_LEFT_LEN                               5120
#define IDC_EDIT_SELECT_PIECE                                                           5121
#define IDC_EDIT_SELECT_SECT_MAC                                                             5122
#define IDC_EDIT_PROBE_TO_MAC_LEFT_LEN                                  5123
#define IDC_EDIT_YARN_TYPE                                                                5124
#define IDC_EDIT_DUMU1_TO_MAC_LEFT_LEN                                5125
#define IDC_EDIT_DUMU3_TO_MAC_LEFT_LEN                                 5126
#define IDC_EDIT_FUEL_GAB                                                                   5127
#define IDC_EDIT_SELECT5_TO_MAC_RIGHT_LEN                             5128
#define IDC_EDIT_MAC_WIDTH                                                               5129
#define IDC_EDIT_SELECT_MODE                                                           5130
#define IDC_EDIT_ROCK_MODE                                                              5131
#define IDC_EDIT_ROCK_ZERO_DIR                                                       5132
#define IDC_EDIT_LANGUAGE_MAC                                                                 5133
#define IDC_EDIT_RED_LIGHT_TIME                                                     5134
#define IDC_EDIT_SEVER_TYPE                                                               5135
#define IDC_EDIT_SELECT_START                                                           5136
#define IDC_EDIT_SINK_DIR                                                                    5137
#define IDC_EDIT_DUMU2_TO_MAC_LEFT_LEN                                5138
#define IDC_EDIT_DUMU4_TO_MAC_LEFT_LEN                                5139
#define IDC_EDIT_FUEL_TIME                                                                 5140
#define IDC_EDIT_SELECT6_TO_MAC_RIGHT_LEN                            5141
#define IDC_EDIT_NULL_DATA                                                                 5142
#define IDC_EDIT_NUM                                                                             5143
#define IDC_EDIT_YARN_SET                                                                    5144
#define IDC_EDIT_MAC_PARAM_SINK1                                                5145
#define IDC_EDIT_MAC_PARAM_SINK2                                                5146


#define IDC_EDIT1                            6000
#define IDC_EDIT2                            6001
#define IDC_LABEL1                         6500
#define ID_BUTTON1                         7000
#define ID_BUTTON2                         7001
#define ID_BUTTON3                         7002
#define ID_BUTTON4                         7003
#define ID_BUTTON5                         7004
#define ID_BACKL_CODE_H                    7500
#define ID_BACKL_CODE_A                    7532
#define ID_FRONTL_CODE_A                   7564
#define ID_FRONTL_CODE_H                   7596
#define ID_BACKR_CODE_H                    7700
#define ID_BACKR_CODE_A                    7732
#define ID_FRONTR_CODE_A                   7764
#define ID_FRONTR_CODE_H                   7796



#define ID_FRONT_1SELECT                   8000
#define ID_FRONT_2SELECT                   8020
#define ID_FRONT_3SELECT                   8040
#define ID_FRONT_4SELECT                   8060
#define ID_BACK_1SELECT                    8500
#define ID_BACK_2SELECT                    8520
#define ID_BACK_3SELECT                    8540
#define ID_BACK_4SELECT                    8560
#define ID_BACK_1CAM                       9000
#define ID_BACK_2CAM                       9020
#define ID_BACK_3CAM                       9040
#define ID_BACK_4CAM                       9060
#define ID_FRONT_1CAM                      9100
#define ID_FRONT_2CAM                      9120
#define ID_FRONT_3CAM                      9140
#define ID_FRONT_4CAM                      9160
#define ID_BACK_1DUMU                      9500
#define ID_FRONT_1DUMU                     9520
#define ID_BACK_DUMU_1SIGN                 9540
#define ID_FRONT_DUMU_1SIGN                9560
#define ID_FRONT_1SINK                      9580
#define ID_BACK_1SINK                          9590
#define ID_BACK_SINK_1SIGN             9600
#define ID_FRONT_SINK_1SIGN           9610
#define ID_CYCLE_GROUP                       9620
#define ID_EDIT3                                         9630
#define ID_EDIT4                                        9640
#define ID_YARN_ALL_COPY                    9641
#define ID_YARN_ALL_ADD                       9642
#define ID_YARN_ALL_MIN                       9643
#define ID_YARN_COPY                              9644
#define ID_YARN_NEXT                               9645
#define ID_YARN_LAST                               9646


enum{
    BMP_XTCS = 0,
    BMP_WORK = 0,
    BMP_MAST = 1,
    BMP_HELP = 2,
    BMP_ROCK_TRAN = 3,
    BMP_DMBZ = 4,
    BMP_YARN_CHANGE = 5,
    BMP_TIME = 6,
    BMP_HEAD_TEST = 7,
    BMP_RUN = 8,
    BMP_RAB = 9,
    BMP_YARN_STOP = 10,
    BMP_SINK = 11,
    BMP_YARN_CHECK = 12,
    BMP_YARN_USED = 13,
    BMP_YARN_NO_USED = 14,
    BMP_FLW = 15,
    BMP_PROGRAM = 16,
    BMP_KEYPANE = 17,
    BMP_FILE = 18,
    BMP_0BIG = 19,
    BMP_1BIG = 20,
    BMP_2BIG = 21,
    BMP_3BIG = 22,
    BMP_4BIG = 23,
    BMP_5BIG = 24,
    BMP_6BIG = 25,
    BMP_7BIG = 26,
    BMP_8BIG = 27,
    BMP_9BIG = 28,
    BMP_ENTER = 29,
    BMP_DEL = 30,
    BMP_MOVE = 31,
    BMP_ESC = 32,
    BMP_ASK = 33,
    BMP_FALSE = 34,
    BMP_TRUE = 35,
    BMP_PASSWORD = 36,
    BMP_ASK_DLG = 37,
    BMP_INFO = 38,
    BMP_INFO_LEN = 39,
    BMP_YES = 40,
    BMP_NO = 41,
    BMP_FILE_INPUT = 42,
    BMP_COMPANY = 43,
    BMP_1DAT = 44,
    BMP_2DAT = 45,
    BMP_3DAT = 46,
    BMP_4DAT = 47,
    BMP_5DAT = 48,
    BMP_6DAT = 49,
    BMP_7DAT = 50,
    BMP_8DAT = 51,
    BMP_9DAT = 52,
    BMP_0DAT = 53,
    BMP_aDAT = 54,
    BMP_bDAT = 55,
    BMP_cDAT = 56,
    BMP_dDAT = 57,
    BMP_eDAT = 58,
    BMP_fDAT = 59,
    BMP_DAT_ESC = 60,
    BMP_DAT_ENTER = 61,
    BMP_COPY = 62,
    BMP_BOARD_TEST = 63,
    BMP_LOG = 64,
    BMP_ACT = 65,
    BMP_RETRY = 66,
    BMP_HEX_DEL = 67,
    BMP_HEX_ESC = 68,
    BMP_HEX_ENTER = 69,
    BMP_KEYPANE_MAC = 70,
    BMP_DAT_AUTO = 71,
    BMP_DAT_ESC1 = 72,
    BMP_RUN_SS = 73,
    BMP_SAVE_SC = 74,
    BMP_FLW_FCS = 75,
    MAX_BMP
};
extern BITMAP g_bmp[MAX_BMP];
extern ushort g_cx_screen;
extern ushort g_cy_screen;

#define CX_SCREEN     (g_cx_screen)
#define CY_SCREEN     (g_cy_screen)
#define CX_EDGE_LEFT       13
#define CX_EDGE_RIGHT      12
#define CY_EDGE_TOP        40  //包含5个像素的边界
#define CY_EDGE_BOTTOM     40  //包含5个像素的边界
#define CY_TITLE4_HEIGHT   50

extern gal_pixel g_color[];
#define COLOR_MH_BK  g_color[0]
#define COLOR_HQ_BKGND(hdc)    (RGB2Pixel (hdc, 0x2A, 0x40, 0x35))
#define COLOR_HQ_YELLOW(hdc)   (RGB2Pixel (hdc, 0xFF, 0xFF, 0x07))
#define COLOR_HQ_GREEN(hdc)    (RGB2Pixel (hdc, 0x00, 0xF8, 0xF8))
#define COLOR_HQ_BLACK(hdc)    (RGB2Pixel (hdc, 0x00, 0x00, 0x00))
#define COLOR_HQ_CYAN(hdc)     (RGB2Pixel (hdc, 0x07, 0xFF, 0x07))
#define COLOR_HQ_WHITE(hdc)    (RGB2Pixel (hdc, 0xF8, 0xF8, 0xF8))
#define COLOR_HQ_GRAY(hdc)     (RGB2Pixel (hdc, 0x57, 0x57, 0x57))
#define COLOR_HQ_RED(hdc)      (RGB2Pixel (hdc, 0xFF, 0x07, 0x07))
#define COLOR_HQ_GREY(hdc)     (RGB2Pixel (hdc, 0x3F, 0x3F, 0x3F))
#define COLOR_HQ_DUSTY(hdc)    (RGB2Pixel (hdc, 0x40, 0x68, 0x78))
#define COLOR_HQ_BLUE(hdc)     (RGB2Pixel (hdc, 0x28, 0x68, 0x90))
#define COLOR_HQ_2GREEN(hdc)   (RGB2Pixel (hdc, 0x18, 0x3F, 0x2F))
#define COLOR_HQ_3GREEN(hdc)   (RGB2Pixel (hdc, 0x17, 0x27, 0x1F))
#define COLOR_HQ_PINK(hdc)     (RGB2Pixel (hdc, 0xFF, 0x80, 0xC0))

#define MAX_LEN   128

#define GET_MAST_WND_BKGND_BMP()    "images/master.bmp"
#define MASTER_WND_CX                502
#define MASTER_WND_CY                348
#define GET_RUN_WND_BKGND_BMP()     "images/run.bmp"
#define GET_BTN_NORM_BMP()          "images/btn_norm.bmp"
#define GET_RESET_NORM_BMP()        "images/reset_norm.bmp"
#define GET_RESET_DOWN_BMP()        "images/reset_down.bmp"
#define GET_HD_NORM_BMP()           "images/hd_norm.bmp"
#define GET_HD_DOWN_BMP()           "images/hd_down.bmp"
#define GET_SPEED_NORM_BMP()        "images/speed_norm.bmp"
#define GET_SPEED_DOWN_BMP()        "images/speed_down.bmp"
#define GET_PIECE_LOCK_NORM_BMP()   "images/piece_lock_norm.bmp"
#define GET_PIECE_LOCK_DOWN_BMP()   "images/piece_lock_down.bmp"
#define GET_HELP_NORM_BMP()         "images/help_norm.bmp"
#define GET_HELP_DOWN_BMP()         "images/help_down.bmp"
#define GET_YARN_UP_NORM_BMP()      "images/yarn_up_norm.bmp"
#define GET_YARN_UP_DOWN_BMP()      "images/yarn_up_down.bmp"
#define GET_WARN_ENABLE_NORM_BMP()  "images/warn_enable_norm.bmp"
#define GET_WARN_ENABLE_DOWN_BMP()  "images/warn_enable_down.bmp"
#define GET_HELP_WND_BMP()          "images/help.bmp"
#define CX_HELP_WND_BMP              450
#define CY_HELP_WND_BMP              350
#define GET_XTCS_WND_BMP()          "images/xtcs.bmp"
#define CX_XTCS_WND_BMP              800
#define CY_XTCS_WND_BMP              480
#define GET_ROCK_TRAN_BMP()         "images/rock_tran.bmp"
#define CX_ROCK_TRAN_BMP             300
#define CY_ROCK_TRAN_BMP             349
#define GET_DMBZ_BMP()              "images/dmbz.bmp"
#define CX_DMBZ_BMP                  195
#define CY_DMBZ_BMP                  299
#define GET_YARN_CHANGE_BMP()       "images/yarn_change.bmp"
#define CX_YARN_CHANGE_BMP           321
#define CY_YARN_CHANGE_BMP           369
#define GET_TIME_BMP()              "images/time.bmp"
#define CX_TIME_BMP                  300
#define CY_TIME_BMP                  200
#define GET_HEAD_TEST_BMP()         "./images/head_test.bmp"
#define CX_HEAD_TEST_BMP             800
#define CY_HEAD_TEST_BMP             600
#define GET_RUN_BMP()               "images/run.bmp"
#define GET_RUN_SS_BMP()         "images/run_ss.bmp"
#define GET_RAB_BMP()               "images/rab.bmp"
#define CX_RAB_BMP                   500
#define CY_RAB_BMP                   306
#define GET_YARN_STOP_BMP()         "images/yarn_stop.bmp"
#define CX_YARN_STOP_BMP             800
#define CY_YARN_STOP_BMP             500
#define GET_SINK_BMP()              "images/sink.bmp"
#define CX_SINK_BMP                  800
#define CY_SINK_BMP                  398
#define GET_YARN_CHECK_BMP()        "images/yarn_check.bmp"
#define CX_YARN_CHECK_BMP            602
#define CY_YARN_CHECK_BMP            200
#define GET_YARN_USED_BMP()         "images/yarn_used.bmp"
#define CX_YARN_USED_BMP             20
#define CY_YARN_USED_BMP             20
#define GET_YARN_NO_USED_BMP()      "images/yarn_no_used.bmp"
#define GET_FLW_BMP()               "images/flw.bmp"
#define CELL_FLW_BMP                 20
#define GET_PROGRAM_BMP()           "images/program.bmp"
#define GET_KEYPANE_BMP()           "images/keypane.bmp"
#define GET_KEYPANE_MAC_BMP()           "images/keypane_mac.bmp"
#define CX_KEYPANE_MAC_BMP           159
#define CY_KEYPANE_MAC_BMP             123
#define CX_KEYPANE_BMP              361
#define CY_KEYPANE_BMP              141
#define GET_FILE_BMP()              "images/file.bmp"
#define CX_FILE_BMP                 500
#define CY_FILE_BMP                 350
#define FILE_LIST_NUM_BY_FILE_BMP    14
#define GET_BIG0_BMP()              "images/0.bmp"
#define GET_BIG1_BMP()              "images/1.bmp"
#define GET_BIG2_BMP()              "images/2.bmp"
#define GET_BIG3_BMP()              "images/3.bmp"
#define GET_BIG4_BMP()              "images/4.bmp"
#define GET_BIG5_BMP()              "images/5.bmp"
#define GET_BIG6_BMP()              "images/6.bmp"
#define GET_BIG7_BMP()              "images/7.bmp"
#define GET_BIG8_BMP()              "images/8.bmp"
#define GET_BIG9_BMP()              "images/9.bmp"
#define CX_BIG_NUM_BMP              48
#define CY_BIG_NUM_BMP              39
#define GET_DEL_BMP()               "images/del.bmp"
#define CX_DEL_BMP                  100
#define CY_DEL_BMP                   39
#define GET_MOVE_BMP()              "images/move.bmp"
#define CX_MOVE_BMP                 83
#define CY_MOVE_BMP                 81
#define GET_ENTER_BMP()             "images/enter.bmp"
#define CX_ENTER_BMP                138
#define GET_ESC_BMP()               "images/esc.bmp"
#define CX_ESC_BMP                  100
#define GET_ASK_BMP()               "images/ask.bmp"
#define GET_FALSE_BMP()             "images/false.bmp"
#define GET_TRUE_BMP()              "images/true.bmp"
#define CX_ASK_BMP                  32
#define CY_ASK_BMP                  32
#define GET_PASSWORD_BMP()          "images/password.bmp"
#define CX_PASSWORD_BMP             200
#define CY_PASSWORD_BMP             110
#define GET_ASK_DLG_BMP()           "images/dlg_ask.bmp"
#define CX_ASK_DLG_BMP              282
#define CY_ASK_DLG_BMP              148
#define GET_INFO_BMP()              "images/info.bmp"
#define CX_INFO_BMP                 200
#define CY_INFO_BMP                 110
#define GET_INFO_LEN_BMP()          "images/info_len.bmp"
#define CX_INFO_LEN_BMP             397
#define CY_INFO_LEN_BMP             110
#define GET_YES_BMP()               "images/yes.bmp"
#define CX_YES_BMP                  75
#define CY_YES_BMP                  35
#define GET_NO_BMP()                "images/no.bmp"
#define CX_NO_BMP                   75
#define CY_NO_BMP                   35
#define GET_FILE_INPUT_BMP()        "images/file_input.bmp"
#define CX_FILE_INPUT_BMP           484
#define CY_FILE_INPUT_BMP           380
#define GET_COMPANY_BMP()           "images/company.bmp"
#define CX_COMPANY_BMP              380
#define CY_COMPANY_BMP              60
#define GET_DAT_1BMP()              "images/dat_1.bmp"
#define GET_DAT_2BMP()              "images/dat_2.bmp"
#define GET_DAT_3BMP()              "images/dat_3.bmp"
#define GET_DAT_4BMP()              "images/dat_4.bmp"
#define GET_DAT_5BMP()              "images/dat_5.bmp"
#define GET_DAT_6BMP()              "images/dat_6.bmp"
#define GET_DAT_7BMP()              "images/dat_7.bmp"
#define GET_DAT_8BMP()              "images/dat_8.bmp"
#define GET_DAT_9BMP()              "images/dat_9.bmp"
#define GET_DAT_0BMP()              "images/dat_0.bmp"
#define GET_DAT_aBMP()              "images/dat_a.bmp"
#define GET_DAT_bBMP()              "images/dat_b.bmp"
#define GET_DAT_cBMP()              "images/dat_c.bmp"
#define GET_DAT_dBMP()              "images/dat_d.bmp"
#define GET_DAT_eBMP()              "images/dat_e.bmp"
#define GET_DAT_fBMP()              "images/dat_f.bmp"
#define CX_DAT_0BMP                 36
#define CY_DAT_0BMP                 27
#define GET_DAT_ESC_BMP()           "images/dat_esc.bmp"
#define GET_DAT_ESC_BMP1()           "images/dat_esc1.bmp"
#define CX_DAT_ESC1_BMP            153
#define CY_DAT_ESC1_BMP            27
#define CX_DAT_ESC_BMP              75
#define CY_DAT_ESC_BMP              27
#define GET_DAT_AUTO_BMP()         "images/dat_auto.bmp"
#define GET_DAT_ENTER_BMP()         "images/dat_enter.bmp"
#define CX_DAT_AUTO_MAP           75
#define CY_DAT_AUTO_MAP           27
#define CX_DAT_ENTER_BMP            75
#define CY_DAT_ENTER_BMP            27
#define GET_COPY_BMP()              "images/copy.bmp"
#define CX_COPY_BMP                 34
#define CY_COPY_BMP                 34
#define GET_BOARD_TEST_BMP()        "images/board_test.bmp"
#define CX_BOARD_TEST_BMP           650
#define CY_BOARD_TEST_BMP           480
#define GET_LOG_BMP()               "images/log.bmp"
#define CX_LOG_BMP                  800
#define CY_LOG_BMP                  600
#define GET_ACT_BMP                 "images/act.bmp"
#define CX_ACT_BMP                  300
#define CY_ACT_BMP                  230
#define GET_RETRY_BMP()             "images/retry.bmp"
#define GET_HEX_DEL_BMP()           "images/hex_del.bmp"
#define CX_HEX_DEL_BMP              40
#define CY_HEX_DEL_BMP              27
#define GET_HEX_ESC_BMP()           "images/hex_esc.bmp"
#define CX_HEX_ESC_BMP              40
#define CY_HEX_ESC_BMP              27
#define GET_HEX_ENTER_BMP()         "images/hex_enter.bmp"
#define CX_HEX_ENTER_BMP            67
#define CY_HEX_ENTER_BMP            27
#define GET_SAVE_SCREEN()                "images/screen.bmp"
#define GET_FLW_FOCUS()                    "images/focus.bmp"

#define MASTER_TITLE_LEFT            114
#define MASTER_TITLE_TOP             5
#define MASTER_TITLE_WIDTH           276
#define MASTER_TITLE_HEIGHT          40

#define FOCUS_BIT                   1
#define IS_FOCUS(n)                (n & FOCUS_BIT)

/*
 *
 */
#define KEY_ESC           27

/*
 * timer id for run wnd
 */
#define TIMER_ID_RUN      1001
#define TIMER_ID_UPDATE   1003

#define KNIT_FILE_DIR     "flower/"
#define GetUsbDir()           "/udisk/"              //   "/media/sda1/"

#include <unistd.h>
#define MH_FILE_SYNC()               sync()

#include "mh/common.h"
#include "mh/mh_knit.h"
#include "mh/mh_file.h"
#include "mh/mac.h"

extern struct MH_KNIT *g_knit_data;
extern char g_edit_text[MH_FILE_NAME_MAX_LEN];
extern int g_edit_index;
extern HWND g_hwnd_run;


#define FREE(p) \
{\
    if(p) \
    { \
        free(p); \
        p = NULL; \
    } \
}

typedef struct _WND_RACK            WND_RACK, *PWND_RACK;
typedef struct _WND_MAC             WND_MAC, *PWND_MAC;
typedef struct _WND_RUN             WND_RUN;
typedef struct _WND_SYS             WND_SYS;
typedef struct _WND_FILE            WND_FILE;
typedef struct _FILE_COPY           FILE_COPY;
typedef struct _WND_FLOWER          FLOWER_WND;
typedef struct _WND_FLOWER          WND_FLOWER, *PWND_FLOWER;
typedef struct _WND_KEYPANE         KEYPANE_DATA, *PKEYPANE_DATA;
typedef struct _WND_KEYPANE         WND_KEYPANE, *PWND_KEYPANE;
typedef struct _WND_DAT             WND_DAT, *PWND_DAT;
typedef struct _WND_INFO            WND_INFO;
typedef struct _WND_TSCAL           WND_TSCAL, *PWND_TSCAL;
typedef struct _WND_SPEED           WND_SPEED, *PWND_SPEED;
typedef struct _WND_DENSITY         WND_DENSITY, *PWND_DENSITY;
typedef struct _WND_RAB             WND_RAB, *PWND_RAB;
typedef struct _WND_RAB             WND_ROLL, *PWND_ROLL;
typedef struct _WND_RAB             WND_SWITCH, *PWND_SWITCH;
typedef struct _WND_ECONOMY         WND_ECONOMY, *PWND_ECONOMY;
typedef struct _WND_ASK             WND_ASK;
typedef struct _WND_LOG             WND_LOG, *PWND_LOG;
typedef struct _WND_ACT             WND_ACT;
typedef struct _WND_WORK            WND_WORK;
typedef struct _WND_MAC_PARAM WND_MAC_PARAM;
typedef struct _WND_DENSITY         WND_YARN_COM;
typedef struct _WND_PROGRAM         WND_PROGRAM, *PWND_PROGRAM;
typedef struct _WND_EXTENT          WND_EXTENT;
typedef struct _WND_FEEDER          WND_FEEDER;
typedef struct _WND_OUTPUT          WND_OUTPUT;
typedef struct _CNT_INFO            CNT_INFO;
typedef struct _WND_BOARD_PARAM     WND_BOARD_PARAM, *PWND_BOARD_PARAM;
typedef struct _WND_YARN_SET           WND_YARN_SET;
typedef struct _WND_BOARD_TEST      WND_BOARD_TEST, *PWND_BOARD_TEST;
typedef struct _WND_UPDATE          WND_UPDATE, *PWND_UPDATE;
typedef struct _WND_CAM                WND_CAM, *PWND_CAM;
typedef struct _WND_SINK                WND_SINK, *PWND_SINK;
typedef struct _WND_YARN_STOP    WND_YARN_STOP;

#pragma pack(1)

struct _WND_WORK {
    union {
        struct {
            uchar sys :1;
            uchar work :1;
            uchar hide :1;
            uchar reset : 1;
            uchar other :1;
            uchar rsvd :4;
        };
        uchar all;
    } change;
    uchar rsvd[3];
};

struct _WND_SYS {
    pthread_t sys_thread_id;
    uchar sys_query_state;
    struct {
        uchar sys : 1;
        uchar work : 1;
        uchar mac : 1;
        uchar other : 1;
        uchar left : 1;
        uchar right : 1;
        uchar reset : 1;
        uchar rsvd : 3;
    }change;
};

struct _WND_MAC_PARAM{
    uchar change;
};

struct _WND_YARN_STOP{
    uchar change;
};

struct _WND_FILE {
    FILE_INFO *file_list;
    ushort list_size;
    ushort over_top;
    uchar active;
    uchar sort_file_type;
};


struct _FILE_COPY {
    char name[2][MH_FILE_NAME_MAX_LEN];
    enum {FILE_COPY_STEP_SEL_FROM = 0,
        FILE_COPY_STEP_SEL_TO} step;
    WND_FILE wnd_file[2];
};


struct _WND_RUN {
    HWND hwnd_tip;
    int error_code;
    int wnd_error;

    uint rab_open : 1;
    uint rab_close : 1;
    uint sort_file_type : 8;
    uint rsvd : 22;
    uint efficiency;

};

struct _WND_RACK {
    uchar rack_query_state;
    pthread_t rack_thread_id;
};

struct _WND_ASK {
    uint yes_no : 1;
    uint ret_value : 1;
    uint rsvd : 30;
};

struct _WND_MAC {
    ushort focus_id;

};

struct _CNT_INFO {
    uchar act;
    ushort codeA;
    ushort codeH;
    ushort height;
    ushort yarn;   //1号纱嘴最高位
};

typedef struct _FUN_PARAM
{
    BYTE dumu;
    BYTE speed;
    BYTE roller;
    BYTE gauze;
    BYTE sink;
} FUN_PARAM;

typedef union _OPT_PARAM
{
    FUN_PARAM param;
    BYTE data[5];   //0,dumu;1,speed;2,roller;3,gauze;4,sink
} OPT_PARAM;

typedef struct _OPT_FUN
{
    ushort con_row;
    ushort cam;        //0, sys1; 1, sys2
    OPT_PARAM all;
} OPT_FUN;

struct _WND_FLOWER {
    ushort x;
    ushort y;
    ushort l;
    ushort b;
    uchar zoom;
    uchar change;
    uchar rsvd[2];
    CNT_INFO cnt_info;
    OPT_FUN *popt;
};

struct _WND_KEYPANE {
    int value;
    int min;
    int max;
    ushort err : 1;
    ushort rsvd : 15;
    short valid;
};

struct _WND_DAT {
    uchar src;
    uchar des;
    uchar rsvd[2];
};

struct _WND_INFO {
    uint len : 1;
    uint modal : 1;
    uint color : 3;
    uint ret : 1;
    uint rsvd : 26;
};

struct _WND_TSCAL {
    int data[5][2];
    int index;
};

struct _WND_SPEED {
    uchar change;
    uchar rsvd[3];
};

struct _WND_DENSITY {
    uchar change;
    uchar rsvd[3];
};

struct _WND_RAB {
    uchar change: 1;
    uchar torque : 1;
    uchar rsvd : 6;
    uchar rsvd2[3];
};

struct _WND_ECONOMY {
    uchar change: 4;
    uchar line:4;
};

struct _WND_SINK {
    uint change;
};
struct _WND_CAM {
    uint change;
};

struct _WND_LOG {
    uchar rsvd1;
    uchar active;
    ushort top;
    ushort size;
    ushort rsvd2;
};

struct _WND_ACT {
    uint src : 6;
    uint des : 6;
    uint rsvd : 20;
};

struct _WND_PROGRAM {
    unsigned char change;
    unsigned char rsvd1;
    unsigned char rsvd2;
    unsigned char rsvd3;
    KNIT_PAGE con;
};

struct _WND_EXTENT {
    uchar yarn_num;
    uchar change;
    uchar rsvd[2];
    uchar ext_yarn[10][16];
};

struct _WND_FEEDER {
    union {
        struct {
            uchar sys :1;
            uchar work :1;
            uchar reset : 1;
            uchar other :1;
            uchar rsvd :4;
            uchar speed :1;
        };
        uchar all;
    } change;
    uchar copy;
    uchar rsvd[2];
};

struct _WND_OUTPUT {
    uint left : 1;
    uint right : 1;
    uint rsvd : 30;
};

struct _WND_BOARD_PARAM {
    union {
        struct {
            uchar sys : 1;
            uchar work : 1;
            uchar other : 1;
            uchar rsvd : 5;
        };
        uchar all;
    }change;
    uchar rsvd;
    short pulse;
};

struct _WND_YARN_SET {
    uchar all ;      //
    uchar page ;
    short focus_id;
};

struct _WND_BOARD_TEST {
    uint roll_act : 1;      //罗拉动作标志
    uint roll_open : 1;     //罗拉打开感应器
    uint board_reset : 1;   //起底板复位标志
    uint board_act : 1;     //起底板动作标志
    uint cs_act : 1;        //剪刀夹子动作标志
    uint cs_wait : 6;       //剪刀夹子等待计数
    uint roll_wait : 8;     //高罗拉打开等待
    uint board_wait : 7;   //起底板动作等待
    uint cs_auto : 3;       //全部动作
    uint cs_syn : 2;        //1-左剪刀联动,2-右剪刀联动
    uint error : 1;
};

struct _WND_UPDATE {
    char file[MH_FILE_NAME_MAX_LEN];
    uchar type;
    char progress;
    char error;
    uchar last_progress;
};

struct _WND_EXTRA_DATA {
    union{
        struct {
            unsigned char speed;
            unsigned char rsvd1;
            unsigned short id;
        }uspeed; //unsigned speed
        int value;
        void *p;
        PWND_PROGRAM pwnd_program;
        FILE_COPY *pfile_copy;
        WND_RUN *pwnd_run;
        WND_RACK *pwnd_rack;
        WND_FILE *pwnd_file_select;
        PWND_MAC pwnd_mac;
        PWND_FLOWER pwnd_flower;
        WND_DAT dat;
        PWND_KEYPANE pwnd_keypane;
        WND_INFO info;
        PWND_TSCAL pwnd_tscal;
        WND_SPEED speed;
        WND_DENSITY density;
        WND_RAB rab;    //主罗拉
        WND_ROLL roll;  //副罗拉
        WND_SWITCH kaihe;
        WND_ECONOMY economy;
        WND_ASK ask;
        WND_FILE *pwnd_file;
        WND_SYS *pwnd_sys;
        PWND_LOG pwnd_log;
        WND_ACT act;
        WND_WORK work;
        WND_MAC_PARAM mac_param;
        WND_YARN_COM yarn_com;
        WND_WORK dist;
        WND_EXTENT *pextent;
        WND_FEEDER feeder;
        WND_OUTPUT output;
        PWND_BOARD_PARAM pwnd_board_param;
        WND_YARN_SET yarn;
        WND_BOARD_TEST board_test;
        PWND_UPDATE pwnd_update;
        WND_SINK  sink;
        WND_CAM  cam;
        WND_YARN_STOP yarn_stop;
    };
};
#pragma pack()

typedef struct _WND_EXTRA_DATA    WND_EXTRA_DATA;

#endif
